/*
 * Copyright (c) 2007 Universidade Federal de Campina Grande
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package br.edu.ufcg.threadcontrol;

import java.util.Collection;
import java.util.HashSet;

public class ThreadConfiguration {

	public static final String STATE_SLEEPING = "Sleeping";
	public static final String STATE_WAITING = "Waiting";
	public static final String STATE_RUNNING = "Running";
	public static final String STATE_FINISHED = "Finished";
	public static final String STATE_STARTED = "Started";
	public static final String STATE_UNKNOWN = "Unknown";
	public static final String STATE_NOTIFIED = "Notified";
	public static final String STATE_POSSIBLY_NOTIFIED = "Possibly notified";
	public static final int ANY_NUMBER_OF_TIMES = 0;

	private String threadClassName;
	private HashSet<String> expectedStates;
	private int timesToBeInStateBeforeBlocking;

	public ThreadConfiguration(String threadClassName, String expectedState,
			int timesToBeInStateBeforeBlocking) {
		this.threadClassName = threadClassName;
		this.setExpectedState(expectedState);
		this.timesToBeInStateBeforeBlocking = timesToBeInStateBeforeBlocking;
	}

	public ThreadConfiguration(String threadClassName, String[] expectedStates,
			int timesToBeInStateBeforeBlocking) {
		this.threadClassName = threadClassName;
		this.expectedStates = new HashSet<String>();
		this.setExpectedStates(expectedStates);
		this.timesToBeInStateBeforeBlocking = timesToBeInStateBeforeBlocking;
	}

	public Collection<String> getExpectedStates() {
		return expectedStates;
	}

	public void setExpectedState(String expectedState) {
		this.setExpectedStates(expectedState);
	}

	public void setExpectedStates(String... states) {
		this.expectedStates = new HashSet<String>();
		for (String s : states) {
			this.expectedStates.add(s);
		}
	}

	public String getThreadClassName() {
		return threadClassName;
	}

	public void setThreadClassName(String threadClassName) {
		this.threadClassName = threadClassName;
	}

	public int getTimesToBeInStateBeforeBlocking() {
		return timesToBeInStateBeforeBlocking;
	}

	public void setTimesToBeInStateBeforeBlocking(
			int timesToBeInStateBeforeBlocking) {
		this.timesToBeInStateBeforeBlocking = timesToBeInStateBeforeBlocking;
	}

}
